/* GUI CONVERTED from reiqchg.p (converter v1.75) Sat Aug 12 23:05:47 2000 */
/* reiqchg.p - REPETITIVE                                                     */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                         */
/*J2DG*/ /*V8:RunMode=Character,Windows                                       */
/* REVISION: 7.3      LAST MODIFIED: 10/31/94   BY: WUG *GN77*                */
/* REVISION: 7.3      LAST MODIFIED: 09/05/95   BY: STR *G0WB*                */
/* REVISION: 9.0      LAST MODIFIED: 04/16/99   BY: *J2DG* Reetu Kapoor       */
/* REVISION: 9.1      LAST MODIFIED: 11/17/99   BY: *N04H* Vivek Gogte        */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */


/*J2DG*/ /* GROUPED MULTIPLE FIELD ASSIGNMENTS INTO ONE AND ADDED NO-UNDO */
/*J2DG*/ /* WHEREVER MISSING AND REPLACED FIND STATEMENTS WITH FOR FIRST  */
/*J2DG*/ /* STATEMENTS FOR ORACLE PERFORMANCE.                            */

/*
SUBPROGRAM TO DETERMINE THE CHANGE IN THE  INPUT  QUEUE  FOR  THE
EARLIEST   PRIOR   CONSECUTIVE  MILESTONE  OPERATION  FOR  A  QTY
PROCESSED.  TRANSACTION.  IF NO NONMILESTONES IMMEDIATELY  PRIOR,
JUST DEFAULTS TO THE CHANGE QTY PASSED IN THE INPUT PARAMETER.

*/


/*G0WB*/  {mfdeclre.i}

          define input parameter cumwo_lot  as character no-undo.
          define input parameter op         as integer   no-undo.
          define input parameter qty_proc   as decimal   no-undo.
          define output parameter inputq_op as integer   no-undo.
          define output parameter qty_chg   as decimal   no-undo.

          define variable new_inque_qty       as decimal no-undo.
          define variable qty_to_proc_this_op as decimal no-undo.

/*N04H**  {rewrsdef.i} */

/*J2DG*/  assign
             inputq_op = op
             qty_chg   = - qty_proc.

/*J2DG**  find wr_route where wr_lot = cumwo_lot and wr_op = op no-lock. */
/*J2DG*/  for first wr_route
/*J2DG*/     fields (wr_lot wr_milestone wr_op wr_qty_inque wr_qty_outque)
/*J2DG*/     where wr_lot = cumwo_lot
/*J2DG*/      and wr_op = op no-lock:
/*J2DG*/  end. /* FOR FIRST WR_ROUTE */

/*N04H**  {rewrsget.i &lot=wr_lot &op=wr_op} */

          new_inque_qty = wr_qty_inque + qty_chg.

          for each wr_route
/*J2DG*/     fields (wr_lot wr_milestone wr_op wr_qty_inque wr_qty_outque)
             no-lock
             where wr_lot = cumwo_lot and wr_op < op
             while not wr_milestone
             by wr_lot descending by wr_op descending:

/*N04H**     {rewrsget.i &lot=wr_lot &op=wr_op} */

/*J2DG*/     assign
                qty_to_proc_this_op = - new_inque_qty - wr_qty_outque
                new_inque_qty       = wr_qty_inque - qty_to_proc_this_op

                qty_chg             = new_inque_qty - wr_qty_inque
                inputq_op           = wr_op.
          end.
